

console.log("==========","ArrayHashTable 测试","==========")

let newHashTable = new ArrayHashTable(4);

console.log("==========","ArrayHashTable.set 测试","==========")
newHashTable.set(1,"A");
newHashTable.set(2,"B");
newHashTable.set(3,"C");
newHashTable.set(4,"D");

let result = eq(4,newHashTable.size);
testPrint(result,"设置键值队")

console.log("==========","ArrayHashTable.get 测试","==========")
let expect = newHashTable.get(1) ;
result = eq("A",expect);
testPrint(result,"获取键对应的值")

expect = newHashTable.get(3) ;
result = eq("C",expect);
testPrint(result,"获取键对应的值")

console.log("==========","ArrayHashTable 键值覆盖测试","==========")
newHashTable.set(5,"A1");
result = eq(4,newHashTable.size);
testPrint(result,"设置键值队")

expect = newHashTable.get(1) ;
result = eq(null,expect);
testPrint(result,"获取键对应的值")

expect = newHashTable.get(5) ;
result = eq("A1",expect);
testPrint(result,"获取键对应的值")

console.log("==========","ArrayHashTable.delete 测试","==========")
newHashTable.delete(5)
expect = newHashTable.get(5) ;
result = eq(null,expect);
testPrint(result,"delete成功")

let ex = [2,3,4];
let arr = newHashTable.keys();
result = eqArrayEle(ex, arr)
testPrint(result, "获取所有的键")

ex = ['B','C','D'];
arr = newHashTable.values();
result = eqArrayEle(ex, arr)
testPrint(result, "获取所有的值")


console.log(newHashTable.entries());

console.log("==============链式哈希表")

let chainHashTable = new HashTableChaining(4);

chainHashTable.set(1,"A");
chainHashTable.set(2,"B");
chainHashTable.set(3,"C");
chainHashTable.set(4,"D");
chainHashTable.set(5,"A1");
chainHashTable.set(6,"B1");

console.log(chainHashTable.get(1)) ;
console.log(chainHashTable.get(5)) ;

console.log("==============哈希算法")

console.log(addHash('abc'))

console.log(mulHash('abc'))

console.log(xorHash('abc'))

console.log(rotHash('abc'))